<?php
namespace app\port\controller;
use app\port\model\School;
use app\port\model\Photo;
use think\Request;
class Schools extends Base
{
    /**
     *获取分页的学校列表
     */
    public function getAllSchool(Request $request){
        $page = $request->post("pageNumber")-1;
        $length = $request->post("length");
        $res = School::limit($page * $length,$length)->select();
        $total = ceil(School::count("id") /$length);
        if($res){
           return $this->request_json_total($res,$total,true);

        }else{
            return $this->request_json($res);
        }

    }
	/**
	 * 获取单个详细的学校信息
	 */
	public function getSchoolDetail(Request $request){
		$res = School::get($request->post('id'));
		
		if($res){
			$photo = Photo::where(["videotype"=>$res['id'],"status"=>1])->select();
			$res['photo'] = $photo;
			return $this->request_json($res,true);
		}else{
			return $this->request_json($res);
		}
	}

}